Skip to content

feat(parser): report error for using declarations in ambient contexts#19934

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-02-feat_parser_report_error_for_using_declarations_in_ambient_contexts
Mar 6, 2026
Merged

feat(parser): report error for using declarations in ambient contexts#19934
graphite-app[bot] merged 1 commit intomainfrom
c/03-02-feat_parser_report_error_for_using_declarations_in_ambient_contexts

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Mar 2, 2026

No description provided.

@camc314 camc314 marked this pull request as ready for review March 2, 2026 20:19
Copilot AI review requested due to automatic review settings March 2, 2026 20:19
Copy link
Contributor Author

camc314 commented Mar 2, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-parser Area - Parser C-enhancement Category - New feature or request labels Mar 2, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the TypeScript parsing diagnostics to explicitly report errors when using / await using declarations appear in ambient contexts (e.g., inside declare namespace / declare module), and refreshes coverage snapshots to reflect the new error codes/messages.

Changes:

  • Emit TS-style diagnostics for using and await using declarations in ambient contexts (TS1545/TS1546).
  • Prevent the generic “initializers not allowed in ambient contexts” diagnostic from firing for using-kind declarators (so the more specific diagnostic is reported instead).
  • Update TypeScript and Babel parser coverage snapshots to match the new diagnostics and pass counts.

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.

File Description
tasks/coverage/snapshots/parser_typescript.snap Updates TypeScript coverage snapshot outputs for the new ambient-context using diagnostics and expected results.
tasks/coverage/snapshots/parser_babel.snap Updates Babel parser fixture snapshot outputs to use TS1545/TS1546 instead of TS1039 for these cases.
crates/oxc_parser/src/js/declaration.rs Adds ambient-context validation for using/await using declarations and avoids overlapping ambient initializer diagnostics for using-kinds.
crates/oxc_parser/src/diagnostics.rs Introduces new TS diagnostics (1545/1546) with messages matching updated snapshots.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 2, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/03-02-feat_parser_report_error_for_using_declarations_in_ambient_contexts (38988ba) with main (b6e9499)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (10e211f) during the generation of this report, so b6e9499 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@camc314 camc314 force-pushed the c/03-02-feat_parser_report_error_for_using_declarations_in_ambient_contexts branch from 7757257 to 38988ba Compare March 6, 2026 16:25
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 6, 2026
Copy link
Contributor Author

camc314 commented Mar 6, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/03-02-feat_parser_report_error_for_using_declarations_in_ambient_contexts branch from 38988ba to e8547cc Compare March 6, 2026 16:34
@graphite-app graphite-app bot merged commit e8547cc into main Mar 6, 2026
22 checks passed
@graphite-app graphite-app bot deleted the c/03-02-feat_parser_report_error_for_using_declarations_in_ambient_contexts branch March 6, 2026 16:41
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 6, 2026
camc314 pushed a commit that referenced this pull request Mar 9, 2026
### 🚀 Features

- e8547cc parser: Report error for using declarations in ambient
contexts (#19934) (camc314)
- 8345318 allocator: Add methods for boxed slices `ArenaBox<[T]>`
(#19968) (overlookmotel)
- f83be30 allocator: Add `Vec::push_fast` method (#19959)
(overlookmotel)

### 🐛 Bug Fixes

- 291d867 transformer_plugins: Unwrap ChainExpression after define
replacement removes optional markers (#20058) (IWANABETHATGUY)
- 36b2e56 codegen: Print type for TSImportEqualsDeclaration (#20128)
(camc314)
- 5a246ec codegen: Print type arguments for JSXOpeningElement (#20127)
(camc314)
- a40870e codegen: Preserve parens for TSNonNullExpression (#20125)
(camc314)
- ae830b2 codegen: Print `declare` for `TSInterfaceDeclaration` (#20124)
(camc314)
- 92cfb14 linter/plugins: Fix types for `walkProgram` and
`walkProgramWithCfg` (#20081) (overlookmotel)
- ee0491e apps,napi: Explicitly specify libs in tsconfigs (#20071)
(camc314)
- 588009e codegen: Print `static` keyword for TSIndexSignature (#19755)
(Dunqing)
- 5a8799c codegen: Print `with_clause` for `ExportNamedDeclaration`
(#20002) (Dunqing)
- 7502afe parser: Correct capacity for tokens `Vec` (#19967)
(overlookmotel)

### ⚡ Performance

- 4ea8f9a napi: Remove `napi_build::setup()` from `oxc_napi` to avoid
redundant rebuilds (#20094) (Boshen)
- 2baa5fb napi: Unify build-test profile to coverage for cache sharing
(#20090) (Boshen)
- 8ba61dd parser: Make pushing tokens faster (#19960) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants